package com.eipc.util;

import android.content.Context;
import android.content.SharedPreferences;

public class Pref {

	/** 配置文件名 */
	private static final String FILE = "version";

	public static final String KEY_HOME = "home";
	public static final String KEY_CONTACT = "contact";

	public static SharedPreferences getPreferences(Context context) {
		return context.getSharedPreferences(FILE, 0);
	}

	public static SharedPreferences.Editor getEditor(Context context) {
		return getPreferences(context).edit();
	}

	public static void setPref(Context context, String key, int value) {
		SharedPreferences.Editor editor = context.getSharedPreferences(FILE, 0)
				.edit();
		editor.putInt(key, value);
		editor.commit();
	}

	public static int getPref(Context context, String key, int defaultValue) {
		return context.getSharedPreferences(FILE, 0).getInt(key, defaultValue);
	}

	public static void clear(Context context) {
		SharedPreferences.Editor editor = getEditor(context);
		editor.clear();
		editor.commit();
		
	}

}
